package com.datasentinel.rooms.ui.sh3d;

import java.awt.EventQueue;

public class DelayedAction implements Runnable
{
	private int count;
	private Runnable action;
	private boolean active;
	private int delay;
	
	public DelayedAction(Runnable action, int delay)
	{
		this.action = action;
		this.delay = delay;
	}
	public void postpone()
	{
		count = 7;
	}
	public void disarm()
	{
		active = false;
		count = 0;
	}
	@Override
	public void run()
	{
		active = true;
		count = 7;
		while (count-- > 0)
		{
			try
			{
				Thread.sleep(delay);
			}
			catch (InterruptedException e)
			{
			}
		}
		if (active)
			EventQueue.invokeLater(action);
	}
}

